import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
export const _import = require('./_import_' + process.env.NODE_ENV)
/* Layout */
import Layout from '@/views/layout/Layout'
// import Layout from '@/views/About'
export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  // {
  //   path: '/resetPassword',
  //   component: () => import('@/views/resetPassword/index'),
  //   hidden: true
  // },
  {
    path: '/404',
    component: () => import('@/views/common/404'),
    hidden: true
  },
  /** 首页 */
  {
    path: '/',
    component: Layout,
    redirect: '/enter_prise',
    // children: [{
    //   path: '/enter_prise',
    //   name: 'enter_prise',
    //   component: () => import('@/views/About.vue'),
    //   meta: { title: '企业资料' }
    // }]
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
